<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<link href="${basePath}/static/css/Pigeonhole/Pigeonhole_list.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="${basePath}/static/css/medicalRecord_Search/medicalSearch.css"/>
<script type="text/javascript" src="${basePath}/static/publics/assets/jqPaginator/jqPaginator.js"></script>
<div class="list_NR">
        <div class="loc">
            <h3>病案打印设置</h3>
       
            </ul>
        </div>
        
        <div class="list_con_table">
            <input type="hidden" value="${medRecordQuery.totalCounts }" id="totalCountsHidden">
			 <form action="" method="get" id="queryForm">
	        	<div class="search_table">
                <ul class="clearfix" style="margin-bottom:0;">
                    
                    <li class="Label_1" style="width:12%">打印类型：&nbsp;</li>
                    <li class="Label_2" style="width:17%">
                    	<select id="mrPrintTypeId" class="input_box" onchange="printData()">
                    		<c:forEach items="${printTypeList}" var="printType" >
                          	   <option value="${printType.id }">${printType.name }</option>
                            </c:forEach>
                        
                        </select>
                    </li>
                   
                   
                   <li class="Label_5">
                        <div class="right">
                        	<input class="btn" type="button" onclick="addPageType()" value="保存">
                        </div>
                    </li>
                </ul>
            </div>
	        </form>
			 
			
        </div>
       
        <div class="Search_tableList" >
           		 <div style="width:100%;" class="tdLabel_5">病案类型  <div style="float:right"><input class="check_cl" onchange="checkAll(this)" type="checkbox" >全选</div></div>
            	<div style="width:20%;float:left" class="tdLabel_5">
            		<!-- <label>1-医嘱离院 <input type="checkbox" checked="checked" class="check_cl"  name='' id='' value='' /></label> -->
            	</div> 

           
        </div>
    </div>
<script type="text/javascript" src="${basePath}/static/publics/assets/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
	
	$(function(){
		init();
	})
	
	
	
	function printData(){
		init();
	}
	
	function init(){
		
		var mrPrintTypeId =$("#mrPrintTypeId").val();
		$.ajax({
			type:"post",
			data:{mrPrintTypeId:mrPrintTypeId},
			url:"${basePath}/medrecord/getPrintData",
			success:function(data){
				var html="<div style='width:100%;' class='tdLabel_4'>病案类型<div style='float:right'>全选&nbsp;<input class='check_cl' onchange='checkAll(this)' type='checkbox' >&nbsp;</div></div>";
				if(data.success){
					console.log(data);
					var printDataList =data.data;
					for(var i=0;i<printDataList.length;i++){
						var printData=printDataList[i];
						var flag=printData.flag;
						if(flag==true){
							html+="<div style='width:20%;float:left' class='tdLabel_6'>"+
		            			  "	<label>"+printData.name+" <input checked='checked'  type='checkbox'  class='check_cl'  name='checkOne' id='' value='"+printData.id+"' /></label>"+
		                		  "	</div>";
						}else{
							html+="<div style='width:20%;float:left' class='tdLabel_6'>"+
	            			  "	<label>"+printData.name+" <input  type='checkbox'  class='check_cl'  name='checkOne' id='' value='"+printData.id+"' /></label>"+
	                		  "	</div>";
						}
					
						//html+="<div style='width:20%;float:left' class='tdLabel_5'>"+${printData.name}+" <input type='checkbox' class='check_cl'  name='pageType'  value='"+${printData.id}+"' /></div>";
					}
					
					$(".Search_tableList").html("").html(html);
					
				}
			}
		})
		
	}
	
	
	//批量选中checkbox
 	function checkAll(obj){
 		var $this=$(obj);
 		//alert($this);
 		if($this.is(':checked')){
 			$("input[type='checkbox'][name='checkOne']").each(function(){
 				$(this).prop("checked",true);
			});
 		}else{
 			$("input[type='checkbox'][name='checkOne']").each(function(){
 				$(this).prop("checked",false);
			});
 		}
 	}
	
	
 	//获取checkbox值
	 function getFormVals(name){
			var arr = [];
			$("input[type='checkbox'][name='"+name+"']:checked").each(function(){
				arr.push($(this).val());	
			});
			return arr.toString();
	}
 	
 	
 	function addPageType(){
 		var pageTypeIds = getFormVals("checkOne");
 		var mrPrintTypeId =$("#mrPrintTypeId").val();
 	
 		$.ajax({
 			type:"post",
 			data:{pageTypeIds:pageTypeIds,mrPrintTypeId:mrPrintTypeId},
 			url:"${basePath}/medrecord/addPageTypes",
 			success:function(data){
 				if(data.success){
 					layer.alert("保存打印类型成功!",{icon:1});
 					init();
 				}
 			}
 		})
 		
 		
 			
 		
 	}
</script>